using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Windows.Forms;
using System.Drawing;

namespace Dogfight2008.Tests
{
  [TestFixture]
  public class GameOverStateFixture
  {
    GameOverState s;

    [SetUp]
    public void Init() {
      s = new GameOverState();
    }

    [Test]
    public void PushingKeyGoesToPressFireState()
    {
      DFState newState = s.KeyDown(Keys.Space);
      Assert.AreEqual(DFState.PressFire, newState);
    }

    [Test]
    public void Waiting1SecondStaysInState()
    {
      DFState newState = s.Tick(1000);
      Assert.AreEqual(DFState.GameOver, newState);
    }

    [Test]
    public void Waiting20SecondsExits()
    {
      DFState newState = s.Tick(20000);
      Assert.AreEqual(DFState.PressFire, newState);
    }

    [Test]
    public void DontFoolMe()
    {
      for (int i = 0; i < 20; i++)
        s.Tick(1000);
      DFState newState = s.Tick(10);
      Assert.AreEqual(DFState.PressFire, newState);
    }

    [Test]
    public void Render()
    {
      MockRenderer renderer = new MockRenderer(
        delegate(
          int cn,
          string text,
          Uniform x,
          Uniform y,
          Uniform height,
          Anchor anchor)
        {
          if (cn == 0)
            Assert.IsTrue(text == "Game Over");
        },
        null);
      s.Render(renderer);
      Assert.IsTrue(renderer.TextAtCalled, null);
    }
  }
}
